﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class GameManager : MonoBehaviour
{
    [Header("房间")]
    public GameObject roomPrefab;       // 房间预制体
    public int roomCount = 5;           // 生成房间数
    public Vector2 firstRoomPosition = Vector2.zero;    // 第一个房间位置坐标
    public Vector2 offset = new Vector2() { x = 0.155f, y = 0.075f };   // 生成新房间的偏移量

    RoomGenerator roomGenerator;

    void Start()
    {
        GameObject roomsObject = GameObject.Find("Rooms");

        roomGenerator = new RoomGenerator(roomPrefab, roomsObject.transform)
        {
            InitialPosition = firstRoomPosition,
            Offset = offset
        };
        roomGenerator.Generate(roomCount);
    }


    void Update()
    {
        if (Input.anyKeyDown)
        {
            roomGenerator.RemoveAll();
            roomGenerator.Generate(roomCount);
        }
    }
}
